package com.twu.biblioteca;


import java.util.ArrayList;
import java.util.Scanner;


public class BibliotecaUI {
    private ArrayList<String> UserOptions = new ArrayList<String>();
    private ArrayList<Customer> customers = new ArrayList<Customer>();

    public BibliotecaUI() {
        InitializeCustomerList();
    }

    private void InitializeCustomerList(){

        customers.add(new Customer("Akhil", "987-8778", "Akhil S", "akhil@gmail.com", "899899876"));
        customers.add(new Customer("Zach", "984-8778", "Zach Jordan", "zach@outlook.com", "989877867678"));
        customers.add(new Customer("John", "985-8778", "John Malkovich", "john@hotmail.com", "9878978978"));
        customers.add(new Customer("Mark", "986-8778", "Mark Morton", "mark@valve.com", "876868678678"));
        customers.add(new Customer("Chris", "983-8778", "Chris Adler", "chris@rockmachine.com", "98768789768"));

    }
    public void DeclareUserOptions(){

      UserOptions.add("1. Display books");
      UserOptions.add("2. Display movies");
      UserOptions.add("3. Return book");
      UserOptions.add("4. Checkout book");
      UserOptions.add("5.Checkout movie");
      UserOptions.add("6.Get account info");
      UserOptions.add("7.Exit");
    }

    public String GetUserOptions(int choice){
        String UserOption;
        switch(choice)
        {
            case 1: UserOption = "Display books";
                break;

            case 2 : UserOption = "Display Movies";
                break;

            case 3: UserOption = "Return Book";
                break;

            case 4: UserOption  = "Checkout book";
                break;

            case 5: UserOption = "Checkout Movie";
                break;

            case 6 :UserOption = "Get account info";
                break;

            case 7: UserOption = "Exit";
                break;

            default : UserOption = "Select a valid option!";
        }
    return UserOption;

    }
    public int DisplayUserOptions(){

        System.out.println("Please select one of the options : ");
        System.out.println("1. Display books \n 2. Display Movies \n 3. Return Book \n4. Checkout book \n5.Checkout Movie \n6.Get account information\n7.Exit");
        int choice = 0;
        Scanner sc = new Scanner(System.in);
        choice=sc.nextInt();
        return choice;



    }


    public boolean performLogin(String username, String password) {

      boolean isValidCustomer = false;
      if(CheckValidCustomer(username,password) == true)
      {
             System.out.println("Login successful!");
             isValidCustomer = true;

      }

        else
      {

          isValidCustomer = false;
          System.out.println("Login failed!");
      }

        return isValidCustomer;
    }


    public   boolean CheckValidCustomer(String username, String password){


        for(Customer customer: customers)
        {
            if(username.equalsIgnoreCase(customer.userName) && password.equals(customer.password))

              return true;

        }
       return false;

    }

}
